package com.example.zqm.git72.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.zqm.git72.Adapter.ClubCourseListAdapter;
import com.example.zqm.git72.Adapter.ClubVideoListAdapter;
import com.example.zqm.git72.JavaBean.ClubCourse;
import com.example.zqm.git72.JavaBean.ClubMap;
import com.example.zqm.git72.JavaBean.ClubVideo;
import com.example.zqm.git72.Model.ClubModel;
import com.example.zqm.git72.R;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


public class ClubVideoActivity extends AppCompatActivity {
   public List<ClubMap> clubVideos;
    RecyclerView recyclerView;
    String id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_clubvideo);
        recyclerView = (RecyclerView) findViewById(R.id.video);
        recyclerView.setLayoutManager(new LinearLayoutManager(ClubVideoActivity.this));//设置布局
        shouData();

    }


    private void shouData() {
        Intent intent = getIntent();
        Bundle bundle=intent.getExtras();
        id=bundle.getString("id");
        //System.err.println("id =" + id);
        ClubModel clubModel = new ClubModel();
        Call<List<ClubMap>> call = clubModel.getTypeList(id, "Clubvideo");
        call.enqueue(new Callback<List<ClubMap>>() {
            @Override
            public void onResponse(Call<List<ClubMap>> call, Response<List<ClubMap>> response) {
                clubVideos = response.body();
                recyclerView.setAdapter(new ClubVideoListAdapter(ClubVideoActivity.this, clubVideos));//设置适配器
                //System.err.println("club course ok");
            }

            @Override
            public void onFailure(Call<List<ClubMap>> call, Throwable t) {
                //System.err.println("club course filed " + t.getLocalizedMessage());

            }
        });
    }
}
